Object.defineProperty(exports, "__esModule", {
    value: !0
}), exports.default = void 0;

var t = require("../@babel/runtime/helpers/defineProperty"), e = require("../@babel/runtime/helpers/toConsumableArray");

require("../@babel/runtime/helpers/Objectvalues");

var a = require("../@babel/runtime/helpers/classCallCheck"), i = require("../@babel/runtime/helpers/createClass"), s = function() {
    function s(t) {
        a(this, s), this.loading = !1, this.finished = !1, this.dataName = t, this.dataPath = "".concat(t), 
        this.pages = 0, this.length = 0, this.limit = 15, this.loadPage = 1;
    }
    return i(s, [ {
        key: "bind",
        value: function(t) {
            return this.PageThis = t, this.clean(), this;
        }
    }, {
        key: "push",
        value: function(t) {
            var a = this.PageThis.data, i = Object.keys(a[this.dataName]).length, s = "page_";
            i > 0 ? Object.values(a[this.dataName]).pop().length >= this.limit ? s += i + 1 : s += i : s += "1";
            var h = "".concat(this.dataPath, ".").concat(s), r = {};
            if (a[this.dataPath][s]) {
                var n = a[this.dataPath][s].length;
                if (Array.isArray(t)) for (var l = 0; l < t.length; l++) {
                    var c = l + n;
                    r["".concat(h, "[").concat(c, "]")] = t[l];
                } else r["".concat(h, "[").concat(n, "]")] = t;
            } else r[h] = Array.isArray(t) ? e(t) : t;
            return this.PageThis.setData(r), this.length += Object.keys(t).length, this.pages++, 
            this.loadPage++, this;
        }
    }, {
        key: "removePage",
        value: function(e) {
            this.PageThis.setData(t({}, "".concat(this.dataPath, ".page_").concat(e), [])), 
            this.pages--;
        }
    }, {
        key: "removeItem",
        value: function(e, a) {
            var i = this, s = "".concat(this.dataPath, ".page_").concat(e), h = this.PageThis.data[this.dataPath]["page_" + e];
            h.splice(a, 1), this.PageThis.setData(t({}, s, h), function() {
                i.length--;
            });
        }
    }, {
        key: "clean",
        value: function() {
            this.pages = 0, this.length = 0, this.loading = !1, this.finished = !1, this.loadPage = 1, 
            this.PageThis.setData(t({}, this.dataPath, {}));
        }
    } ]), s;
}();

exports.default = s;